package tech.aistar.util;

import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;

public class RedisUtil {
    @Resource
    private RedisTemplate<String, Object> redisTemplates;
    public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
        this.redisTemplates = redisTemplate;
    }
    public long incr(String key, long delta){
        if(delta<0){
            throw new RuntimeException("递增因子必须大于0");
        }
        return redisTemplates.opsForValue().increment(key, delta);
    }
}
